<template>
  <div class="package-wrap" style="padding-top: 50px">
    <van-nav-bar
      title="礼包详情"
      left-arrow
      fixed
      @click-left="$router.go(-1)"
    />
  <div class="info" v-html="this.$route.params.data.content"></div>
  <div class="submit">
    <van-button type="info" block @click="submit">{{ this.$route.params.data.price }} 张专属券 购买</van-button>
  </div>
  </div>
</template>
<script>
import { Dialog ,Toast } from 'vant';
import axios from 'axios'
export default {
  props:{
    store_id : {
      type: String || Number,
      required: true
    }
  },
  data(){
    return {
      // list:[],
    }
  },
  methods:{
    submit(){
      Toast.loading({
        message: '加载中...',
        forbidClick: true,
        duration: 0, // 持续展示 toast
      });
      let params = {
        token: sessionStorage.getItem('token'),
        store_id:this.store_id
      }
      axios.post(`/api/store/user/tera/buy/${this.$route.params.data.id}`,params).then(res=>{
        Toast.clear()
        Dialog({ message: res.data.message });
      }).catch(err=>{
        Toast.clear()
        Dialog({ message: err.response.data.message });
      })
    },
  },
}
</script>
<style lang="less">
.package-wrap {
  .info {
    min-height: 65vh;
  }
  .submit {
    padding: 0.7692rem 1.1538rem
  }
}
</style>
